package com.learnyou.server.xingzuo.biz.common.impl;

import com.baidu.aip.ocr.AipOcr;
import com.learnyou.server.xingzuo.biz.common.AipOcrBiz;
import com.learnyou.server.xingzuo.common.config.AipOcrConfig;
import com.learnyou.server.xingzuo.common.helper.AipOcrHelper;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;

@Slf4j
@Service
public class AipOcrBizImpl implements AipOcrBiz {

    @Resource
    private AipOcrConfig ocrConfig;


    @Override
    public String businessLicense(String image) {
        AipOcr client = AipOcrHelper.getAipOcrClient(ocrConfig);
        JSONObject object = client.businessLicense(image, new HashMap<>());
        return object.toString();
    }
}
